#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include "ToolMillAutoOffset.h"
using namespace std;
extern "C" 
{
	int creatNewScr(char* str,int len)
	{
		char* sc = new char[len];
		for (int i = 0; i<len; i++){ sc[i] = str[i * 4]; }
		// cout << sc << endl;	
		string tmp = sc;
		int flag = tmp.find(".scr");
		tmp = tmp.substr(0,flag + 4);
		//cout << tmp << endl;
		int flag1 = 0;
		int flag2 = 0;
		flag1 = tmp.find_first_of("|");
		string codes = tmp.substr(0,flag1);
		flag2 = tmp.find_first_of("|", flag1 + 1);
		string T_valueOfCode = tmp.substr(flag1 + 1, flag2 - flag1 - 1);
		flag1 = flag2;
		flag2 = tmp.find_first_of("|", flag1 + 1);
		string values = tmp.substr(flag1 + 1, flag2 - flag1 - 1);
		string scrPathOfRead = tmp.substr(flag2 + 1);
		printf("codes.....:%s",codes);
		//cout << "codes:" << codes << endl;
		//cout << "T_valueOfCode:" << T_valueOfCode << endl;
		//cout << "values:" << values << endl;
		//cout << "scrPathOfRead:" << scrPathOfRead << endl;

		RelatedCodesOffset myRelateOffset;
		Method method; 			
		string contentOfRegionScr = method.readScr(scrPathOfRead);
                //method.creatScrFile("/mysite/fileData2/ST/scr/test.scr1" ,"read OK");
		string offsetContent = myRelateOffset.getRelatedCodsOffset(codes, T_valueOfCode, values, contentOfRegionScr);
		//method.creatScrFile("/mysite/fileData2/ST/scr/test.scr1" ,"read OK");
		//cout << offsetContent << endl;
		int isOk=0;
		isOk=method.creatScrFile("/mysite/fileData2/ST/scr/test.scr" ,offsetContent);
		return isOk;
		//return offsetContent.length() ;
		//return contentOfRegionScr;
}
}


